<?php

class session
{
   static public function open($name=null) 
   {
      if (null != $name) {
         session_name($name);
      }
      @session_start();   //silently ignored if the session has been already opened
   }

   static public function set($name, $val) 
   {
      $_SESSION[$name] = $val;
   }

   static public function has($name) 
   {
      return isset($_SESSION[$name]);
   }

   static public function get($name) 
   {
      assert(self::has($name));
      return $_SESSION[$name];
   }

   static public function del($name) 
   {   
      unset($_SESSION[$name]);
   }

   static public function clear() 
   {
      session_unset();
   }

      //Make sure to call this before doing the header("Location:") redirect 
   static public function close() 
   {
      session_write_close();
   }

   static public function destroy() 
   {
      if (false === session_destroy()) {
         throw new Exception('session_destroy');
      }
   }
};

?>